package com.jzj.Entity;

import java.util.Arrays;
import java.util.List;

public class Teacher {

    private String name;

    private Course[] courses;

    private List<Student> students;

    public String getName() {
        return name;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("Teacher {");
        sb.append("name='").append(name).append('\'');
        sb.append(", courses=").append(Arrays.toString(courses));

        // 处理 students 列表，避免递归调用 Student.toString
        sb.append(", students=[");
        if (students != null) {
            for (int i = 0; i < students.size(); i++) {
                Student student = students.get(i);
                sb.append("{name='").append(student.getName()).append('\'')
                        .append(", age=").append(student.getAge()).append('}');
                if (i < students.size() - 1) {
                    sb.append(", ");
                }
            }
        } else {
            sb.append("null");
        }
        sb.append("]}");

        return sb.toString();
    }

    public void setName(String name) {
        this.name = name;
    }

    public Course[] getCourses() {
        return courses;
    }

    public void setCourses(Course[] courses) {
        this.courses = courses;
    }

    public List<Student> getStudents() {
        return students;
    }

    public void setStudents(List<Student> students) {
        this.students = students;
    }

    public Teacher() {
    }

    public Teacher(String name, Course[] courses, List<Student> students) {
        this.name = name;
        this.courses = courses;
        this.students = students;
    }
}
